TK thank you that fixed that one. But now im having the same problem with my other two axis. This is the c program.
#include "KMotionDef.h"
// Homing program for a 3 axis System
// Limit switches are disabled and used as a home switch
// then they are re-enabled
#define XHOME 168
#define YHOME 169
#define ZHOME 170
void DoHome(int axis, float speed, int dir, int bit, int
polarity, float sensoroffset);
main()
{
persist.UserData[12] = 0;
DoHome( 2, // XSaw
20000, // speed steps/sec
-1, // direction to
home
2, // home input bit
1, // bit polarity (0
or 1) when tripped
1000); // amount to move
back inside (counts)
}
void DoHome(int axis, float speed, int dir, int bit, int
polarity, float sensoroffset)
{
float oppdir = dir * -1;
EnableAxis(axis);
if(ReadBit(bit)==polarity)
{
Jog(axis, speed * oppdir); //
start moving
while (ReadBit(bit) == polarity) ; // wait
for switch (input #8) to change
Jog(axis,0); // stop
MoveRelAtVel(axis,sensoroffset *
oppdir,speed);
while(!CheckDone(1));
}
Jog(axis, speed * dir); // start
moving
//printf("%d \n",persist.UserData[10]);
while (ReadBit(bit) != polarity)
{
persist.UserData[12] = 0;
// send message to console
} // wait for switch (input #44) to change
if(ReadBit(bit)== polarity)
{
persist.UserData[12] = 1; // Signal MM that
homing has completed
//printf("%d \n",persist.UserData[10]);
}
Jog(axis,0); // stop
while(!CheckDone(1));
MoveRelAtVel(axis,sensoroffset * oppdir,speed);
Zero(0);
//EnableAxisDest(axis,0);
}
--- In DynoMotion@yahoogroups.com, TK <tk@...> wrote:
>
> Hi Stephen,
>
> I see some CheckDone and Zero function calls that are passing axis 0 rather than the axis variable which is 1. Try correcting those.
>
> Regards
>
> TK
>
> On Oct 12, 2012, at 5:17 PM, "stephen_lamarr" <stephen_lamarr@...> wrote:
>
> > I am having problems with my homing sequence. If I am off my home sensor and home everything is fine. I end up in homed position with my home sensor flagged. If I home again after homing, the machine should come off the sensor then index back to the sensor. This is not always happening. Most of the time it will come off the sensor and not index back to the sensor. It is inconsistant. Doesn't always come off the sensor then index back like it should. Below is a copy of the c program I am using for homing. Please help.
> >
> > #include "KMotionDef.h"
> >
> > // Homing program for a 3 axis System
> > // Limit switches are disabled and used as a home switch
> > // then they are re-enabled
> >
> > #define XHOME 168
> > #define YHOME 169
> > #define ZHOME 170
> > void DoHome(int axis, float speed, int dir, int bit, int polarity, float sensoroffset);
> >
> > main()
> > {
> > persist.UserData[10] = 0;
> > DoHome( 1, // X
> > 30000, // speed steps/sec
> > 1, // direction to home
> > 0, // home input bit
> > 1, // bit polarity (0 or 1) when tripped
> > 1000); // amount to move back inside (counts)
> >
> > }
> > void DoHome(int axis, float speed, int dir, int bit, int polarity, float sensoroffset)
> > {
> > float oppdir = dir * -1;
> >
> > EnableAxis(axis);
> > if(ReadBit(bit)==polarity)
> > {
> > Jog(axis, speed * oppdir); // start moving
> > while (ReadBit(bit) == polarity) ; // wait for switch (input #8) to change
> > Jog(axis,0); // stop
> > MoveRelAtVel(axis,sensoroffset * oppdir,speed);
> > while(!CheckDone(0));
> > }
> >
> > Jog(axis, speed * dir); // start moving
> > //printf("%d \n",persist.UserData[10]);
> > while (ReadBit(bit) != polarity)
> > {
> > persist.UserData[10] = 0;
> >
> > // send message to console
> > } // wait for switch (input #44) to change
> > if(ReadBit(bit)== polarity)
> > {
> > persist.UserData[10] = 1; // Signal MM that homing has completed
> > //printf("%d \n",persist.UserData[10]);
> > }
> > Jog(axis,0); // stop
> > while(!CheckDone(0));
> >
> > MoveRelAtVel(axis,sensoroffset * oppdir,speed);
> > Zero(0);
> > //EnableAxisDest(axis,0);
> > }
> >
> >
>